require 'pandoc-ruby'

task default: [:docs, :run]

task :run do
    ruby 'app.rb'
end

task :clean do
    #IO.foreach('.gitignore') { |item|
    #    puts("Deleting #{item}")
    #    File.delete(item) if File::exists?(item) 
    #}
    `rm -rf $(cat .gitignore)`
end

task :docs => [:readme] do
    puts('Finish building all documents')
end

task :readme do
    input = File.open('Readme.org', 'r')
    output = File.open('Readme.md', 'w')
    content = PandocRuby.convert(input.read(), from: :org, to: :markdown)
    if output
        output.syswrite(content)
    end
end
